<?php

namespace app\api\controller\notify;

use app\logic\single\group\GroupOrderSingle;
use app\logic\single\OrderEntitySingle;
use app\logic\single\OrderMusicSingle;
use app\logic\single\OrderVipSingle;
use app\logic\single\pay\AliPaySingle;
use app\Request;
use think\facade\Log;

class Ali
{
    /**
     * @var array|mixed
     */
    private $post;
    /**
     * @var int
     */
    private $pay_type = 10;

    function __construct(Request $request)
    {
        $this->post = $request->param();
        Log::write($request->param(),'ali-pay-notify');
        Log::write(AliPaySingle::getInstance()->verifyNotify($this->post),'ali-pay-verifyNotify');
        if(!AliPaySingle::getInstance()->verifyNotify($this->post)){
            echo "fail";die;
        }
    }
    function music_notify(){
        $res = OrderMusicSingle::getInstance()->complete($this->post['out_trade_no'],$this->pay_type,$this->post);
        dump($res);die;
    }
    function vip_notify(){
        $res = OrderVipSingle::getInstance()->complete($this->post['out_trade_no'],$this->pay_type,$this->post);
        dump($res);die;
    }
    function entity_notify(){
        $res = OrderEntitySingle::getInstance()->complete($this->post['out_trade_no'],$this->pay_type,$this->post);
        dump($res);die;
    }
    function group_notify(){
        $res = GroupOrderSingle::getInstance()->complete($this->post['out_trade_no'],$this->pay_type,$this->post);
        dump($res);die;
    }
}